package assist.datastore;

import com.google.appengine.api.rdbms.dev.LocalRdbmsService;
import com.google.appengine.tools.development.testing.LocalRdbmsServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;

/**
 * This contains a helper for using a local, populated DB for read-only SQL tests.
 * TODO: Create a SQL database that is re-set after tests, for read-write SQL tests.
 * TODO: Create setup for tests that use datastore. (Read only, and read-write?)
 *       * Look at old code for the datastore setup.
 */
public class LocalDatastoreHelper
{
    private LocalServiceTestHelper helper;
    
    public void setUpPopulatedDb() 
    {
        LocalRdbmsServiceTestConfig config = new LocalRdbmsServiceTestConfig();
        config.setServerType(LocalRdbmsService.ServerType.LOCAL);
        config.setDriverClass("com.mysql.jdbc.Driver");
        config.setDatabase("hockeystats");
        config.setJdbcConnectionStringFormat("jdbc:mysql://localhost/hockeystats");
        config.setUser("root");
        config.setPassword("mysql");
        
        helper = new LocalServiceTestHelper(config);
        helper.setUp();
    }
    
    public void tearDownDb() 
    {
        helper.tearDown();
    }
    
}
